package t_941

func validMountainArray(array []int) bool {
	len := len(array)
	left := 0
	right := len - 1

	if right-left < 2 {
		return false
	}

	for left < right {
		if array[left] >= array[left+1] {
			break
		}
		left++
	}

	for left < right {
		if array[right] >= array[right-1] {
			break
		}
		right--
	}

	result := left == right && left != 0 && right != len-1
	return result
}
